using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using Iacym.Entities;

namespace Iacym.Repository.Mapping
{
    public class AgendumMap : EntityTypeConfiguration<Agendum>
    {
        public AgendumMap()
        {
            // Primary Key
            this.HasKey(t => t.Id);

            // Properties
            this.Property(t => t.Id)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);

            this.Property(t => t.Motivo)
                .IsRequired()
                .HasMaxLength(100);

            // Table & Column Mappings
            this.ToTable("AGENDA");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.PersonaId).HasColumnName("PersonaId");
            this.Property(t => t.FechaInicio).HasColumnName("FechaInicio");
            this.Property(t => t.FechaFin).HasColumnName("FechaFin");
            this.Property(t => t.Motivo).HasColumnName("Motivo");

            // Relationships
            this.HasRequired(t => t.PERSONA)
                .WithMany(t => t.AGENDA)
                .HasForeignKey(d => d.PersonaId);

        }
    }
}
